import Vue from 'vue'
import Vuex from 'vuex'

import { getItem, setItem } from '@/utils/storage'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    tokenInfo: getItem('tokenInfo') || {}
  },
  mutations: {
    setTokenINfo (state, tokenObj) {
      // 保存到vuex中
      state.tokenInfo = tokenObj
      // 保存到本地
      setItem('tokenInfo', tokenObj)
    }
  },
  actions: {
  },
  modules: {
  }
})
